package com.csxy.yhj.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.csxy.yhj.entity.CareSe;
import com.csxy.yhj.entity.vo.CareFrontVo;
import com.csxy.yhj.entity.vo.CareWebVo;
import com.csxy.yhj.service.CareSeService;

import com.csxy.yhj.yhj.R;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/eduservice/coursefront")
public class CareFrontController {
    @Autowired
    private CareSeService careSeService;
    //@Autowired
    //private EduChapterService chapterService;

    @PostMapping("getFrontCourseList/{page}/{limit}")
    public R getFrontCourseList(@PathVariable long page, @PathVariable long limit,
                                @RequestBody(required = false) CareFrontVo careFrontVo){
        Page<CareSe> pageCourse = new Page<>(page,limit);
        Map<String,Object> map = careSeService.getCareFrontInfo(pageCourse,careFrontVo);
        //返回分页所有数据
        return R.ok().data(map);
    }

    //2.服务详情的方法
    @GetMapping("getFrontCourseInfo/{courseId}")
    public R getFrontCourseInfo(@PathVariable String courseId, HttpServletRequest request) {
        //根据服务id ,编写sql语句查询服务信息
        CareWebVo courseWebVo = careSeService.getBaseCareInfo(courseId);
        return R.ok().data("courseWebVo",courseWebVo);//.data("chapterVideoList",chapterVideoList);
    }
}
